package lc.com.lcpicturebackend.manager.websocket;

import org.apache.ibatis.annotations.ResultMap;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

import jakarta.annotation.Resource;

/**
 * 功能： websocket配置（定义连接）
 * 作者：lc
 * 日期：2025/4/28 1:36
 */
@Component
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Resource
    private WsHandshakeInterceptor wsHandshakeInterceptor;

    @Resource
    private PictureEditHandler pictureEditHandler;
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(pictureEditHandler, "/ws/picture/edit")
                .addInterceptors(wsHandshakeInterceptor)
                .setAllowedOrigins("*");
    }
}
